package by.kniazhych.core.controllers.actions {
	import by.kniazhych.core.controllers.GameController;
	import by.kniazhych.core.controllers.AbstractServerAction;
	import by.kniazhych.core.server.common.ServerCommands;
	import by.vaukalak.core.commands.Command;
	import by.vaukalak.core.utils.applyConstructor;
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
	
	
	public class ServerActionsFactory{
		
		public function ServerActionsFactory() {
			
		}

		public function generateAction(target:GameController, command:Command):AbstractServerAction {
			command.unshift(target);
			switch (command.name) {
				case ServerCommands.DISPLAY_PEACE_CHOISE:
					return applyConstructor(DisplayPeaceChoise, command);
				break;
				case ServerCommands.BUILD_GAME:
					return applyConstructor(BuildGameAction, command);
				break;
				case ServerCommands.PROCESS_MOTION:
					return applyConstructor(ProcessMotionAction, command);
				break;
				case ServerCommands.NOTIFY_USER:
					return applyConstructor(NotifyUserAction, command);
				break;
				case ServerCommands.CHANGE_PEACE:
					return applyConstructor(ChangePeaceAction, command);
				break;
				case ServerCommands.GIVE_TURN:
					return applyConstructor(GiveTurnAction, command);
				break;
				default: throw new ArgumentError();
			}
		}
		
	}

}